project(util LANGUAGES CXX)

file(GLOB_RECURSE SRCS "*.cpp" "*.hpp")
file(GLOB_RECURSE HEADERS "*.h")

foreach(cppfile IN LISTS SRCS)
	message(STATUS "add ${cppfile} to ${PROJECT_NAME}-shared")
endforeach()

set(SHARED_LIB ${PROJECT_NAME}_shared)

# 在Windows下需要添加这一句，Windows下链接动态库需要由.lib文件，否则链接失败，这句就是用来生成.lib文件的
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) 

add_library(${SHARED_LIB} SHARED  ${SRCS} ${HEADERS})

target_include_directories(${SHARED_LIB} PUBLIC
	${jsoncpp_SOURCE_DIR}/include
	${CMAKE_CURRENT_SOURCE_DIR}
)

target_link_libraries(${SHARED_LIB} PUBLIC
	jsoncpp_lib
)

set(STATIC_LIB ${PROJECT_NAME}_static)

add_library(${STATIC_LIB} STATIC  ${SRCS} ${HEADERS})

target_include_directories(${STATIC_LIB} PUBLIC
	${jsoncpp_SOURCE_DIR}/include
	${CMAKE_CURRENT_SOURCE_DIR}
)

target_link_libraries(${STATIC_LIB} PUBLIC
	jsoncpp_lib
)

#set_target_properties(${SHARED_LIB} PROPERTIES
#    OUTPUT_NAME util
#    POSITION_INDEPENDENT_CODE ON
#)